From bfc32f815413ddf338bca18fa6eedddeba46818f Mon Sep 17 00:00:00 2001 From: "cl349@freefall.cl.cam.ac.uk" Date: Fri, 27 Aug 2004 15:57:04 +0000 Subject: [PATCH] bitkeeper revision 1.1159.61.1 (412f59d0QmtgAMJvSE3LvKxxaMUfZg) Call domain_crash() instead of BUG() if something goes wrong with writabel pagetables. --- xen/arch/x86/memory.c | 69 +++++++++++++++++++++++++++++-------------- xen/common/domain.c | 3 ++ 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/memory.c b/xen/arch/x86/memory.c index 778edf0ee1..f6a5657798 100644 --- a/xen/arch/x86/memory.c +++ b/xen/arch/x86/memory.c @@ -1488,8 +1488,10 @@ void ptwr_reconnect_disconnected(unsigned long addr) addr, ptwr_info[cpu].disconnected << L2_PAGETABLE_SHIFT)); pl2e = &linear_l2_table[ptwr_info[cpu].disconnected]; - if (__get_user(pte, writable_pte)) - BUG(); + if (__get_user(pte, writable_pte)) { + MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte); + domain_crash(); + } pfn = pte >> PAGE_SHIFT; page = &frame_table[pfn]; @@ -1512,8 +1514,10 @@ void ptwr_reconnect_disconnected(unsigned long addr) continue; if (unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT)) put_page_from_l1e(ol1e, current); - if (unlikely(!get_page_from_l1e(nl1e, current))) - BUG(); + if (unlikely(!get_page_from_l1e(nl1e, current))) { + MEM_LOG("ptwr: Could not re-validate l1 page\n"); + domain_crash(); + } } unmap_domain_mem(pl1e); update_l2e(pl2e, *pl2e, nl2e); @@ -1525,13 +1529,17 @@ void ptwr_reconnect_disconnected(unsigned long addr) frame_table[pfn].u.inuse.domain->domain)); ptwr_info[cpu].disconnected = ENTRIES_PER_L2_PAGETABLE; /* make pt page write protected */ - if (__get_user(pte, writable_pte)) - BUG(); + if (__get_user(pte, writable_pte)) { + MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte); + domain_crash(); + } PTWR_PRINTK(("[A] writable_l1 at %p is %08lx\n", writable_pte, pte)); pte &= ~_PAGE_RW; - if (__put_user(pte, writable_pte)) - BUG(); + if (__put_user(pte, writable_pte)) { + MEM_LOG("ptwr: Could not update pte at %p\n", writable_pte); + domain_crash(); + } __flush_tlb_one(ptwr_info[cpu].writable_l1); PTWR_PRINTK(("[A] writable_l1 at %p now %08lx\n", writable_pte, pte)); @@ -1564,8 +1572,10 @@ void ptwr_flush_inactive(void) for (idx = 0; idx < ptwr_info[cpu].writable_idx; idx++) { unsigned long *writable_pte = (unsigned long *)&linear_pg_table [ptwr_info[cpu].writables[idx]>>PAGE_SHIFT]; - if (__get_user(pte, writable_pte)) - BUG(); + if (__get_user(pte, writable_pte)) { + MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte); + domain_crash(); + } pfn = pte >> PAGE_SHIFT; page = &frame_table[pfn]; PTWR_PRINTK(("[I] alloc l1 page %p\n", page)); @@ -1579,8 +1589,10 @@ void ptwr_flush_inactive(void) continue; if (unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT)) put_page_from_l1e(ol1e, current); - if (unlikely(!get_page_from_l1e(nl1e, current))) - BUG(); + if (unlikely(!get_page_from_l1e(nl1e, current))) { + MEM_LOG("ptwr: Could not re-validate l1 page\n"); + domain_crash(); + } } unmap_domain_mem(pl1e); @@ -1588,8 +1600,10 @@ void ptwr_flush_inactive(void) PTWR_PRINTK(("[I] writable_l1 at %p is %08lx\n", writable_pte, pte)); pte &= ~_PAGE_RW; - if (__put_user(pte, writable_pte)) - BUG(); + if (__put_user(pte, writable_pte)) { + MEM_LOG("ptwr: Could not update pte at %p\n", writable_pte); + domain_crash(); + } __flush_tlb_one(ptwr_info[cpu].writables[idx]); PTWR_PRINTK(("[I] writable_l1 at %p now %08lx\n", writable_pte, pte)); @@ -1690,8 +1704,11 @@ int ptwr_do_page_fault(unsigned long addr) PTWR_PRINTK(("update %p pte to %08lx\n", &linear_pg_table[addr>>PAGE_SHIFT], pte)); if ( __put_user(pte, (unsigned long *) - &linear_pg_table[addr>>PAGE_SHIFT]) ) - BUG(); + &linear_pg_table[addr>>PAGE_SHIFT]) ) { + MEM_LOG("ptwr: Could not update pte at %p\n", (unsigned long *) + &linear_pg_table[addr>>PAGE_SHIFT]); + domain_crash(); + } return 1; } } @@ -1713,8 +1730,11 @@ static void ptwr_init_backpointers(void) page = &frame_table[pde >> PAGE_SHIFT]; /* assert that page is an l1_page_table XXXcl maybe l2? */ - if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) - BUG(); + if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) { + MEM_LOG("ptwr: Inconsistent pagetable: pde %x is not an l1 page\n", + pde >> PAGE_SHIFT); + domain_crash(); + } page->u.inuse.type_info &= ~PGT_va_mask; page->u.inuse.type_info |= va_idx << PGT_va_shift; } @@ -1739,8 +1759,10 @@ void ptwr_status(void) unsigned long *writable_pte = (unsigned long *)&linear_pg_table [ptwr_info[cpu].writables[i]>>PAGE_SHIFT]; - if ( __get_user(pte, writable_pte) ) - BUG(); + if ( __get_user(pte, writable_pte) ) { + MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte); + domain_crash(); + } pfn = pte >> PAGE_SHIFT; page = &frame_table[pfn]; @@ -1757,8 +1779,11 @@ void ptwr_status(void) ptwr_info[cpu].disconnected << L2_PAGETABLE_SHIFT); pl2e = &linear_l2_table[ptwr_info[cpu].disconnected]; - if ( __get_user(pte, (unsigned long *)ptwr_info[cpu].writable_l1) ) - BUG(); + if ( __get_user(pte, (unsigned long *)ptwr_info[cpu].writable_l1) ) { + MEM_LOG("ptwr: Could not read pte at %p\n", (unsigned long *) + ptwr_info[cpu].writable_l1); + domain_crash(); + } pfn = pte >> PAGE_SHIFT; page = &frame_table[pfn]; diff --git a/xen/common/domain.c b/xen/common/domain.c index 55621847d0..314f875511 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -152,6 +152,9 @@ void domain_crash(void) { struct domain *d; + if (current->domain == 0) + BUG(); + set_bit(DF_CRASHED, ¤t->flags); d = find_domain_by_id(0); -- 2.30.2